
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:yyads_text/banner/banner.dart';
import 'package:yyads_text/splash/splash.dart';

part 'package:yyads_text/callback.dart';

class YyadsText {
  static const MethodChannel _channel =
      const MethodChannel('yyads_text');

  static Future init()async{
    await _channel.invokeMethod('init');
  }


  ///# 开屏广告
  ///
  ///广告回调[SplashCallBack splashCallBack]
  ///
  static Widget  showSplash({
    required SplashCallBack splashCallBack
  }){return SplishView(
    splashCallBack: splashCallBack,
  );
  }

  ///# 得到激励视频
  ///
  static Future<bool>  getRewardVideoAd({
    double? width,
    double? height,
  })async{
    if(width == null){
      width = double.infinity;
    }
    if(height == null){
      height = 300.0;
    }
    return await _channel.invokeMethod("getRewardVideoAd",{
      "width":width.toString(),
      "height":height.toString()
    });
  } 

  ///# 展示激励视频视频
  ///
  static Future<bool> showRewardVideoAd()async{
    return await _channel.invokeMethod("showreward");
  }
  ///# 展示激励视频视频
  ///
  static Future showRewardVideo()async{
    return await _channel.invokeMethod("showreward");
  }
  ///# 展示banner广告
  ///
  static Widget showBanner({
    required BannerCallBack bannerCallBack,
    required double width,
    required double height,
  }){
    return BannerView(bannerCallBack: bannerCallBack,width: width,height: height,); 
  }

  ///# 得到全屏视频广告
  ///
  static Future<bool> getFullVideoAd()async{
    return await _channel.invokeMethod("getFullVideoAd");
  }

  ///# 展示全屏视频广告
  ///
  static Future showFullVideoAd()async{
    await _channel.invokeMethod("showFullVideoAd");
  }

  static Future<String?> getVersion()async{
    final String? version = await _channel.invokeMethod('getVersion');
    return version;
  }
}
